<%@ page language="java"
	import="java.util.*,com.chj.constants.Constants" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'add_network.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" type="text/css"
			href="themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="themes/icon.css">
		<script type="text/javascript" src="js/jquery-1.4.4.min.js">
</script>
		<script type="text/javascript" src="js/jquery.easyui.min.js">
</script>
		<script type="text/javascript">
function mes(a, b, c) {
	$.messager.alert(a,
			"<div style=\"margin-top:10px;width:200px; text-align:center;color:red\">"
					+ b + "<div>", c);
};
$(function() {
	$('#tt').tree( {
		onClick : function(node) {
			$('#tt').tree('beginEdit', node.target);
		}
	});
	$(".easyui-tree li a").click(function() {
		var name = $(this).attr("id") + ":" + $(this).text();
		$("h3").text(name);
	});
});
$(function() {

	$("#ok").click(function() {

		var i = 1;

		$(".easyui-validatebox").each(function() {
			if ($(this).val() == "") {
				mes('系统提示', '请把信息填写完整!', 'warning');
				i = 0;
				return false;
			}
		});

		if (i == 1) {
			ajaxSubmit();
		}
	});
});

function ajaxSubmit() {

	var networkName = $('#networkName').val();
	var networkParkSize = $('#networkParkSize').val();
	var networkProvince = $('#networkProvince').val();
	var networkCity = $('#networkCity').val();
	var networkArea = $('#networkArea').val();
	var networkAddress = $('#networkAddress').val();
	var networkPrice = $('#networkPrice').val();
	var networkTimeBegin = $('#networkTimeBegin').val();
	var networkTimeEnd = $('#networkTimeEnd').val();
	var networkType = $('#networkType').find('option:selected').attr('value');

	//get parameter
	var netWorkStr = {
		networkName : networkName,
		networkParkSize : networkParkSize,
		networkProvince : networkProvince,
		networkCity : networkCity,
		networkArea : networkArea,
		networkAddress : networkAddress,
		networkPrice : networkPrice,
		networkTimeBegin : networkTimeBegin,
		networkTimeEnd : networkTimeEnd,
		networkType : networkType
	}

	$.ajax({type:"post",
               dataType:"text",
               timeout:30000,
               async:true,
               url:"admin/add_network_submit.do",
               data:{netWorkStr:JSON.stringify(netWorkStr)},
               success:function (data) {

                   var result =  eval('(' + data + ')');
                   if (result.<%=Constants.OPERATION_CODE%> == '0') {
                        mes('系统提示', result.<%=Constants.ALERT_MESSAGE%>, 'warning');
                   } else if (result.<%=Constants.OPERATION_CODE%> == '1') {
                        mes('系统提示', result.<%=Constants.ALERT_MESSAGE%>, 'warning');
                        document.frm.reset();
                   } else {
                	   document.frm.reset();
                   }
               },
               error:function (data) {
            	   mes('系统提示', '提交出现问题，提交失败!', 'warning');
               }
       });
    }

    </script>
		<style>
* {
	margin: 0
}

.easyui-tree a {
	text-decoration: none;
	color: #FF9933
}

input {
	width: 200px;
	margin: 5px;
}

font {
	color: red
}
</style>

	</head>

	<body>
		<body>
			<div
				style="width: 700px; height: 530px; float: left; border: 1px solid #99BBE8; font-size: 14px; margin: 8px; color: #4180D1; font-family: Tahoma, Verdana, 微软雅黑, 新宋体;">
				<div
					style="background-image: url(themes/default/images/datagrid_title_bg.png); width: 700px; height: 25px; border-bottom: 1px solid #99BBE8;"></div>
				<div style="width: 500px; float: left;">
					<br>
					<div align="center" style="margin-left: 20px;">
						<div id="title" style="text-align: center; color: #F93">
							<h3>
								充电网点添加
							</h3>
						</div>
						<form id="frm" name="frm" action="admin/add_network_submit.do"
							method="post">
							<table width="400" border="0" align="center">
								<tr>
									<td>
										网点名称：
									</td>
									<td>
										<input id="networkName" name="networkName" type="text"
											class="easyui-validatebox" required="true" />
									</td>
								</tr>
								<tr>
									<td>
										车位数量：
									</td>
									<td>
										<input id="networkParkSize" name="networkParkSize" type="text"
											class="easyui-numberbox" required="true" />
									</td>
								</tr>
								<tr>
									<td>
										网点省份：
									</td>
									<td>
										<input id="networkProvince" id="" type="text"
											class="easyui-validatebox" name="networkProvince"
											required="true" />
									</td>
								</tr>
								<tr>
									<td>
										网点城市：
									</td>
									<td>
										<input id="networkCity" type="text" class="easyui-validatebox"
											name="networkCity" required="true" />
									</td>
								</tr>
								<tr>
									<td>
										网点地区：
									</td>
									<td>
										<input id="networkArea" type="text" class="easyui-validatebox"
											name="networkArea" required="true" />
									</td>
								</tr>
								<tr>
									<td>
										网点详细地址：
									</td>
									<td>
										<textarea id="networkAddress" name="networkAddress"
											style="width: 200px; height: 40px; margin: 5px;"></textarea>
									</td>
								</tr>
								<tr>
									<td>
										网点价格（元/小时）：
									</td>
									<td>
										<input id="networkPrice" name="networkPrice" type="text"
											class="easyui-numberbox" required="true" />
									</td>
								</tr>
								<tr>
									<td>
										网点营业时间开始：
									</td>
									<td>
										<input id="networkTimeBegin" name="networkTimeBegin"
											type="text" class="easyui-timespinner" type="text"
											required="true" value="08:00" />
									</td>
								</tr>
								<tr>
									<td>
										网点营业结束时间：
									</td>
									<td>
										<input id="networkTimeEnd" name="networkTimeEnd" type="text"
											class="easyui-timespinner" type="text" required="true"
											value="20:00" />
									</td>
								</tr>
								<tr>
									<td>
										网点类型：
									</td>
									<td>
										<select id="networkType" name=”networkType”
											class=”easyui-combobox” style="”width: 200px;">
											<option id="1" value="1" selected="selected">
												普通网点
											</option>
										</select>
									</td>
								</tr>
								<tr>
									<td>
										网点图片：
									</td>
									<td>
										<input id="netWorkPicture" name="netWorkPicture" type="file" />
									</td>
								</tr>
								<tr>
									<td></td>
									<td align="center">
										<a id="ok" class="easyui-linkbutton" iconCls="icon-ok">确认</a><a
											class="easyui-linkbutton" iconCls="icon-reload"
											onclick="javascript:document.frm.reset()">重置</a>
									</td>
								</tr>
							</table>
						</form>
					</div>
				</div>
			</div>
		</body>
</html>
